<!-- #INCLUDE Virtual="/lib.asp" -->
<!-- #INCLUDE Virtual="/lib_gen.asp" -->

<%
dim rss, objXMLDom, objXMLdata
dim rssTitle, rssInhoud
const rssError = "Geen JIRA data ontvangen"
rssInhoud = rssError

Set objXMLDom = Server.CreateObject("Microsoft.XMLDOM")
objXMLDom.preserveWhiteSpace = true
objXMLDom.async = false
objXMLDom.resolveExternals = false

objXMLDom.setProperty "SelectionNamespaces", "xmlns=""http://www.w3.org/2005/Atom"" xmlns:atlassian=""http://streams.atlassian.com/syndication/general/1.0"" xmlns:thr=""http://purl.org/syndication/thread/1.0"" xmlns:activity=""http://activitystrea.ms/spec/1.0/"""

Dim http: Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")

on error resume next

'Always specify username/password here, for fail safety
http.open "GET", "https://issues.onehippo.com/sr/jira.issueviews:searchrequest-xml/15233/SearchRequest-15233.xml?tempMax=2000", False,"",""
http.setRequestHeader "Authorization", "Basic " & application("Jira_Key") '& Base64Encode("username:password")
http.send

rss = http.responseText

objXMLDom.loadXML(rss)
Set objXMLdata = objXMLDom.documentElement

dim story, todo, doing, done
todo = 0
doing = 0
done = 0
for each item in objXMLdata.selectNodes("//item")
	story = item.selectSingleNode("summary").text
	status = item.selectSingleNode("status").text 
	key = replace(item.selectSingleNode("key").text, "POLITIENL-", "")
	if rssInhoud = rssError then rssInhoud = ""
	
	select case lcase(status)
	case "in sprint"
		rssInhoudDoing = rssInhoudDoing & "<div><span class='sprint-key'>" & key & "</span> " & server.htmlEncode(story) & "</div>"
		doing = doing + 1
	case "done"
		rssInhoudDone = rssInhoudDone & "<div><span class='sprint-key'>" & key & "</span> " & server.htmlEncode(story) & "</div>"
		done = done + 1
	case else
		rssInhoudTodo = rssInhoudTodo & "<div><span class='sprint-key'>" & key & "</span> " & server.htmlEncode(story) & "</div>"
		todo = todo + 1
	end select
next

dim extraTodo, extraDoing, extraDone
'if todo > doing and todo > done then extraTodo = " sprint-large"
'if doing > todo and doing > done then extraDoing = " sprint-large"
'if done > todo and done > doing then extraDone = " sprint-large"
'if (extraTodo & extraDoing & extraDone = "") then extraDone = " sprint-large"

stories = todo + doing + done
todoStyle = "width: " & 15 + cint((todo/stories)*55) & "%;"
doingStyle = "width: " & 15 + cint((doing/stories)*55) & "%;"
doneStyle = "width: " & 15 + cint((done/stories)*55) & "%;"

rssInhoud = rssInhoud & "<div style='" & todoStyle & "' class='sprint-todo" & extraTodo & "'>TODO (" & todo & ")<br/>" & rssInhoudTodo & "</div>"
rssInhoud = rssInhoud & "<div style='" & doingStyle & "' class='sprint-doing" & extraDoing & "'>DOING (" & doing & ")<br/>" & rssInhoudDoing & "</div>"
rssInhoud = rssInhoud & "<div style='" & doneStyle & "' class='sprint-done" & extraDone & "'>DONE (" & done & ")<br/>" & rssInhoudDone & "</div>"

script = "" 'vbcrlf & "<script>" & vbcrlf & "var p=0;" & vbcrlf & "function roll() { " & vbcrlf & "	p=p+1" & vbcrlf & "	$('#container').scrollTop(p);" & vbcrlf & "	if ($('#container').scrollTop() == p) setTimeout('roll()',50);" & vbcrlf & "}" & vbcrlf & "setTimeout('roll()',3000);" & vbcrlf & "</script>" & vbcrlf
call generatePageTimed(request("preview"), request.querystring("nextpage"), "Huidige sprint", rssImage, "<div style='overflow: hidden; height: 70%; padding-bottom: 100px;' id='container'>" & rssInhoud & "</div>" & script, 30)
%>